﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace HlELock.Domain.Migrations
{
    public partial class init : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "CardLogs",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CardNumber = table.Column<string>(maxLength: 64, nullable: true),
                    CardType = table.Column<string>(maxLength: 64, nullable: true),
                    RoomNumber = table.Column<string>(maxLength: 64, nullable: true),
                    CardAction = table.Column<int>(nullable: false),
                    BeinTime = table.Column<DateTime>(nullable: true),
                    EndTime = table.Column<DateTime>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CardLogs", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "CheckIns",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    Name = table.Column<string>(maxLength: 64, nullable: true),
                    Gender = table.Column<string>(maxLength: 64, nullable: true),
                    IdType = table.Column<string>(maxLength: 64, nullable: true),
                    IdNumber = table.Column<string>(maxLength: 64, nullable: true),
                    Contact = table.Column<string>(maxLength: 64, nullable: true),
                    Days = table.Column<int>(nullable: false),
                    BeginTime = table.Column<DateTime>(nullable: false),
                    EndTime = table.Column<DateTime>(nullable: false),
                    CarNumber = table.Column<string>(maxLength: 64, nullable: true),
                    OrderAttribute = table.Column<string>(maxLength: 64, nullable: true),
                    OrderInfo = table.Column<string>(maxLength: 64, nullable: true),
                    PayWay = table.Column<string>(maxLength: 64, nullable: true),
                    RoomNumber = table.Column<string>(maxLength: 64, nullable: true),
                    CashPledge = table.Column<string>(maxLength: 64, nullable: true),
                    RoomPrice = table.Column<string>(maxLength: 64, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CheckIns", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "HotelInfos",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CompanyName = table.Column<string>(maxLength: 64, nullable: true),
                    UniformCreditCode = table.Column<string>(maxLength: 64, nullable: true),
                    Legal = table.Column<string>(maxLength: 64, nullable: true),
                    CellPhone = table.Column<string>(maxLength: 64, nullable: true),
                    HomePhone = table.Column<string>(maxLength: 64, nullable: true),
                    ProjectName = table.Column<string>(maxLength: 64, nullable: true),
                    Province = table.Column<string>(maxLength: 64, nullable: true),
                    City = table.Column<string>(maxLength: 64, nullable: true),
                    Counties = table.Column<string>(maxLength: 64, nullable: true),
                    Address = table.Column<string>(maxLength: 64, nullable: true),
                    HotelCode = table.Column<string>(maxLength: 64, nullable: true),
                    AgencyCode = table.Column<string>(maxLength: 64, nullable: true),
                    AgencyName = table.Column<string>(maxLength: 64, nullable: true),
                    Password = table.Column<string>(maxLength: 64, nullable: true),
                    HotelType = table.Column<int>(nullable: false),
                    Sector = table.Column<string>(maxLength: 64, nullable: true),
                    ProvinceCode = table.Column<int>(nullable: false),
                    CityCode = table.Column<int>(nullable: false),
                    CountiesCode = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_HotelInfos", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "LocalUsers",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    Account = table.Column<string>(maxLength: 64, nullable: true),
                    Password = table.Column<string>(maxLength: 64, nullable: true),
                    Name = table.Column<string>(maxLength: 64, nullable: true),
                    Role = table.Column<int>(maxLength: 8, nullable: false),
                    Post = table.Column<string>(maxLength: 64, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LocalUsers", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Posts",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    Name = table.Column<string>(maxLength: 64, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Posts", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "Rooms",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    BuldingName = table.Column<string>(maxLength: 64, nullable: true),
                    BuildingNumber = table.Column<int>(nullable: false),
                    FloorNumber = table.Column<int>(nullable: false),
                    RoomNumber = table.Column<string>(maxLength: 64, nullable: true),
                    RoomType = table.Column<string>(maxLength: 64, nullable: true),
                    IsOccupancies = table.Column<bool>(nullable: false),
                    Feature = table.Column<string>(maxLength: 64, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Rooms", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "RoomTypes",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    Index = table.Column<int>(nullable: false),
                    Name = table.Column<string>(maxLength: 64, nullable: true),
                    Feature = table.Column<string>(maxLength: 64, nullable: true),
                    Price = table.Column<decimal>(nullable: false),
                    WeekendPrice = table.Column<decimal>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RoomTypes", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "CheckInRooms",
                columns: table => new
                {
                    Id = table.Column<int>(nullable: false)
                        .Annotation("Sqlite:Autoincrement", true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CheckInId = table.Column<int>(nullable: false),
                    RoomNumber = table.Column<string>(maxLength: 64, nullable: true),
                    RoomType = table.Column<string>(maxLength: 64, nullable: true),
                    Feature = table.Column<string>(maxLength: 64, nullable: true),
                    Price = table.Column<decimal>(nullable: false),
                    CheckInTime = table.Column<DateTime>(nullable: false),
                    CheckOutTime = table.Column<DateTime>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CheckInRooms", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CheckInRooms_CheckIns_CheckInId",
                        column: x => x.CheckInId,
                        principalTable: "CheckIns",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_CheckInRooms_CheckInId",
                table: "CheckInRooms",
                column: "CheckInId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "CardLogs");

            migrationBuilder.DropTable(
                name: "CheckInRooms");

            migrationBuilder.DropTable(
                name: "HotelInfos");

            migrationBuilder.DropTable(
                name: "LocalUsers");

            migrationBuilder.DropTable(
                name: "Posts");

            migrationBuilder.DropTable(
                name: "Rooms");

            migrationBuilder.DropTable(
                name: "RoomTypes");

            migrationBuilder.DropTable(
                name: "CheckIns");
        }
    }
}
